package com.pan.kang.common;


import com.pan.kang.bean.EmployeeSearcherBean;
import com.pan.kang.vo.EmployeeVo;
import org.mapstruct.Mapper;

import java.util.ArrayList;
import java.util.List;

@Mapper(componentModel = "spring")
public abstract class Transfer {

    public EmployeeVo searcherBeanToVo(EmployeeSearcherBean searcherBean) {
        EmployeeVo employeeVo = new EmployeeVo();
        employeeVo.setId(searcherBean.getId());
        employeeVo.setName(searcherBean.getName());
        employeeVo.setGender(searcherBean.getGender());
        employeeVo.setAge(searcherBean.getAge());
        employeeVo.setEntryDate(searcherBean.getEntryDate());
        employeeVo.setDepartmentId(searcherBean.getDepartmentId());
        employeeVo.setDepartmentName(searcherBean.getDepartmentName());
        return employeeVo;
    }

    public List<EmployeeVo> searcherBeanListToVoList(List<EmployeeSearcherBean> searcherBeanList) {
        List<EmployeeVo> employeeVoList = new ArrayList<>();
        for (EmployeeSearcherBean searcherBean : searcherBeanList) {
            EmployeeVo employeeVo = new EmployeeVo();
            employeeVo.setId(searcherBean.getId());
            employeeVo.setName(searcherBean.getName());
            employeeVo.setGender(searcherBean.getGender());
            employeeVo.setAge(searcherBean.getAge());
            employeeVo.setEntryDate(searcherBean.getEntryDate());
            employeeVo.setDepartmentId(searcherBean.getDepartmentId());
            employeeVo.setDepartmentName(searcherBean.getDepartmentName());
            employeeVoList.add(employeeVo);
        }
        return employeeVoList;
    }
}
